<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="70px">
      <el-form-item label="订单编号" prop="orderSn" label-width="85px">
        <el-input style="width: 150px;" v-model="queryParams.orderSn" placeholder="请输入订单编号" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="退款单编号" prop="refundSn" label-width="85px">
        <el-input style="width: 150px;" v-model="queryParams.refundSn" placeholder="请输入退款单编号" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="退款单编号" prop="refundSn">
        <el-input
          v-model="queryParams.refundSn"
          placeholder="请输入退款单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="退款单状态" prop="refundStatus" label-width="85px">
        <el-select style="width: 120px;" v-model="queryParams.refundStatus" placeholder="请选择">
          <el-option v-for="dict in refundStatusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
        </el-select>
        <!-- <el-select v-model="queryParams.refundStatus" placeholder="请选择退款单状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select> -->
      </el-form-item>
      <el-form-item label="退款单审批进度" prop="approveStatus" label-width="110px">
        <el-select style="width: 120px;" v-model="queryParams.approveStatus" placeholder="请选择">
          <el-option v-for="dict in approveStatusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
        </el-select>
        <!-- <el-select v-model="queryParams.refundStatus" placeholder="请选择退款单状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select> -->
      </el-form-item>
      <!-- <el-form-item label="退款方式" prop="refundWay">
        <el-input style="width: 150px;" v-model="queryParams.refundWay" placeholder="请输入退款方式" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="订单商品名称" prop="goodsName" label-width="100px">
        <el-input style="width: 150px;" v-model="queryParams.goodsName" placeholder="请输入订单商品名称" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" size="mini" @click="handleSetRemark()" :disabled="single">客服备注</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" size="mini" @click="openApproval()" :disabled="single">打款审批</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" size="mini" @click="handleManualPayment()" :disabled="single">系统退款</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['orderRefund:refund:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['orderRefund:refund:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['orderRefund:refund:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['orderRefund:refund:export']"
        >导出</el-button>
      </el-col> -->
    </el-row>

    <el-table v-loading="loading" border stripe :data="refundList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" fixed="left" width="55" align="center" />

      <el-table-column label="订单编号" fixed="left" align="center" prop="orderSn" width="150" />
      <el-table-column label="退款单编号" align="center" prop="refundSn" width="150" />
      <el-table-column label="支付金额" align="center" prop="moneyPaid">
        <template slot-scope="scope">
          <span>{{ scope.row.moneyPaid || 0 }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="订单状态" align="center" prop="orderStatus" :formatter="orderStatusFormat" /> -->
      <el-table-column label="店铺名称" align="center" prop="supplierName" />
      <el-table-column label="店长姓名" align="center" prop="realName" />
      <el-table-column label="店长手机号" align="center" prop="userPhone" width="120" />
      <el-table-column label="退款单创建时间" align="center" prop="createTime" width="180" />
      <el-table-column label="退款原因" align="center" prop="refundReason" :formatter="refundReasonFormat" />
      <el-table-column label="退款备注" align="center" prop="refundReasonRemark" />
      <el-table-column label="退款金额" align="center" prop="refundMoney" width="120" />
      <el-table-column label="退款状态" align="center" prop="refundStatus" :formatter="refundStatusFormat" width="120" />
      <el-table-column label="退款审批进度" align="center" prop="approveStatus" :formatter="approveStatusFormat" width="120" />
      <el-table-column label="退款审批时间" align="center" prop="approveDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.approveDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="退款打款时间" align="center" prop="refundDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(exchangeTime(scope.row.refundDate), '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="客服备注" align="center" prop="kfRemark" width="280" />
      <!-- <el-table-column label="退运费金额" align="center" prop="refundShipping" width="120" />
      <el-table-column label="退款方式" align="center" prop="refundWay" /> -->
      <el-table-column label="退款人unionid" align="center" prop="userId" width="250" />

      <!-- <el-table-column label="订单商品" align="center" prop="goodsName" width="120" />
      <el-table-column label="退货退款商品数量" align="center" prop="goodsNumber" width="150" /> -->
      <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width" width="120">
        <template slot-scope="scope">
          <el-button v-if="(scope.row.refundStatus !== 'DISPOSED') && (scope.row.refundStatus !== 'UN_REFUND')" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['orderRefund:refund:edit']">修改退款金额</el-button>
          <el-button size="mini" type="text" @click="handleShowOrderList(scope.row)">关联订单</el-button>
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['orderRefund:refund:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['orderRefund:refund:remove']"
          >删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 订单列表 -->
    <el-dialog title="关联订单" :visible.sync="isShowOrderList" width="1500px" append-to-body>
      <el-table border stripe :data="orderList">
        <el-table-column label="订单号" align="center" prop="orderSn" />
        <el-table-column label="订单状态" align="center" prop="orderStatus" :formatter="orderStatusFormat" />
        <el-table-column label="商品名称" align="center" prop="goodsName" />
        <el-table-column label="商品属性" align="center" prop="goodsAttr" />
        <el-table-column label="商品数量" align="center" prop="goodsNumber" />
        <el-table-column label="订单总价" align="center" prop="goodsAmount" />
        <el-table-column label="店长减免" align="center" prop="adminDiscount" />
        <el-table-column label="结算价" align="center" prop="cost" />
        <el-table-column label="收益" align="center" prop="commission" />
        <el-table-column label="提现状态" align="center" prop="withdState" :formatter="withdStateFormat" />
        <!-- 是否到账 -->
      </el-table>
    </el-dialog>
    <el-dialog title="系统退款确认" :visible.sync="isShowAmountInput" width="400px" append-to-body center>
      <div class="my-refund-row">订单编号：{{refundRow.orderSn || ''}}</div>
      <div class="my-refund-row">订单状态：{{orderStatusFormat(refundRow) || ''}}</div>
      <div class="my-refund-row">支付金额：￥{{refundRow.moneyPaid || 0}}</div>
      <div class="my-refund-row">退款金额：￥{{refundRow.refundMoney || 0}}</div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="systemRefundMoney()">确定退款</el-button>
        <el-button @click="closeShowAmountInput">取消退款</el-button>
      </div>
    </el-dialog>
    <el-dialog title="修改备注" :visible.sync="isShowRemarkInput" width="200" append-to-body>
      <el-input v-model="remarkInputVal" type="textarea" placeholder="请输入备注信息"></el-input>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleEditData()">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改退款单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body center>
      <el-form ref="form" :model="form" :rules="rules" label-width="75px">
        <!-- <el-form-item label="唯一ID" prop="id">
          <el-input v-model="form.id" placeholder="请输入唯一ID" />
        </el-form-item>
        <el-form-item label="是否有效">
          <el-select v-model="form.isActive" placeholder="请选择是否有效">
            <el-option
              v-for="dict in isActiveOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="租户ID" prop="lesseeId">
          <el-input v-model="form.lesseeId" placeholder="请输入租户ID" />
        </el-form-item>
        <el-form-item label="用户ID" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入用户ID" />
        </el-form-item>
        <el-form-item label="店铺ID" prop="supplierId">
          <el-input v-model="form.supplierId" placeholder="请输入店铺ID" />
        </el-form-item>
        <el-form-item label="订单ID" prop="orderId">
          <el-input v-model="form.orderId" placeholder="请输入订单ID" />
        </el-form-item>
        <el-form-item label="订单编号" prop="orderSn">
          <el-input v-model="form.orderSn" placeholder="请输入订单编号" />
        </el-form-item>
        <el-form-item label="退款单编号" prop="refundSn">
          <el-input v-model="form.refundSn" placeholder="请输入退款单编号" />
        </el-form-item>
        <el-form-item label="退款单状态">
          <el-radio-group v-model="form.refundStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="退款原因" prop="refundReason">
          <el-input v-model="form.refundReason" placeholder="请输入退款原因" />
        </el-form-item> -->
        <div class="my-refund-row">订单编号：{{form.orderSn || ''}}</div>
        <div class="my-refund-row">订单状态：{{orderStatusFormat(form) || ''}}</div>
        <div class="my-refund-row">支付金额：￥{{form.moneyPaid || 0}}</div>
        <!-- <el-form-item label="支付金额" prop="moneyPaid">
          <div>￥{{form.moneyPaid || 0}}</div>
        </el-form-item> -->
        <el-form-item label="退款金额:" prop="refundMoney">
          <el-input v-model="form.refundMoney" placeholder="请输入退款金额(不能大于支付金额)" />
        </el-form-item>
        <!-- <el-form-item label="退运费金额" prop="refundShipping">
          <el-input v-model="form.refundShipping" placeholder="请输入退运费金额" />
        </el-form-item>
        <el-form-item label="退款方式" prop="refundWay">
          <el-input v-model="form.refundWay" placeholder="请输入退款方式" />
        </el-form-item>
        <el-form-item label="订单商品ID" prop="supplierGoodsId">
          <el-input v-model="form.supplierGoodsId" placeholder="请输入订单商品ID" />
        </el-form-item>
        <el-form-item label="订单商品名称" prop="goodsName">
          <el-input v-model="form.goodsName" placeholder="请输入订单商品名称" />
        </el-form-item>
        <el-form-item label="退货退款商品数量" prop="goodsNumber">
          <el-input v-model="form.goodsNumber" placeholder="请输入退货退款商品数量" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="打款审批" :visible.sync="showApproval" width="400px" append-to-body center>
      <el-form ref="approvalForm" :model="approvalObject" label-width="0px">
        <el-form-item style="display: flex;justify-content: center;">
          <el-radio-group v-model="approvalObject.approvalStatus" style="margin-bottom: 0">
            <el-radio v-for="dict in approveStatusOptions" :key="dict.dictValue" v-if="dict.dictValue !== 'APPROVING'"
              :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveApproval">确 定</el-button>
        <el-button @click="closeApproval">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    listRefund,
    getRefund,
    delRefund,
    addRefund,
    updateRefund,
    exportRefund,
    toApprove,
    systemRefund
  } from "@/api/orderRefund/refund";
  import {
    getOrderInfo
  } from "@/api/orderInfo/orderInfo";

  import {
    getWithdrawal
  } from "@/api/suppliers/withdrawal"

  export default {
    name: "Refund",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        isShowRemarkInput: false,
        remarkInputVal: "",
        isShowAmountInput: false,
        refundRow: {},
        amountInputVal: "",
        // 总条数
        total: 0,
        // 退款单表格数据
        refundList: [],
        orderList: [],
        showApproval: false,
        approvalObject: {
          approvalStatus: ''
        },
        isShowOrderList: false,
        orderStatusOptions: [],
        refundReasonOptions: [],
        refundStatusOptions: [],
        approveStatusOptions: [],
        withdStateOptions: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 是否有效字典
        isActiveOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderSn: undefined,
          refundSn: undefined,
          refundStatus: undefined,
          approveStatus: undefined
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {}
      };
    },
    created() {
      this.getList();
      this.getDicts("is_active").then(response => {
        this.isActiveOptions = response.data;
      });
      this.getDicts("SHOP_ORDER_STATUS").then(response => {
        this.orderStatusOptions = response.data;
      });
      this.getDicts("SHOP_ORDER_REFUND_REASON").then(response => {
        this.refundReasonOptions = response.data;
      });
      this.getDicts("SHOP_ORDER_REFUND_STATUS").then(response => {
        this.refundStatusOptions = response.data;
      });
      this.getDicts("APPROVE_STATUS").then(response => {
        this.approveStatusOptions = response.data;
      });
      this.getDicts("SHOP_PROFIT_STATUS").then(response => {
        this.withdStateOptions = response.data;
      });
    },
    methods: {
      exchangeTime(timeStr) {
        let str = '';
        if (timeStr && timeStr.length > 0) {
          Date.prototype.Format = function(fmt) {
            var o = {
              'M+': this.getMonth() + 1, // 月份
              'd+': this.getDate(), // 日
              'h+': this.getHours(), // 小时
              'm+': this.getMinutes(), // 分
              's+': this.getSeconds(), // 秒
              'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
              'S': this.getMilliseconds() // 毫秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
            for (var k in o)
              if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) :
                (('00' + o[k]).substr(('' + o[k]).length)));
            return fmt;
          };
          str = new Date(timeStr).Format('yyyy-MM-dd hh:mm:ss');
        }
        return str
      },
      withdStateFormat(row, column) {
        return this.selectDictLabel(this.withdStateOptions, row.withdState);
      },
      approveStatusFormat(row, column) {
        return this.selectDictLabel(this.approveStatusOptions, row.approveStatus);
      },
      refundStatusFormat(row, column) {
        return this.selectDictLabel(this.refundStatusOptions, row.refundStatus);
      },
      refundReasonFormat(row, column) {
        return this.selectDictLabel(this.refundReasonOptions, row.refundReason);
      },
      orderStatusFormat(row, column) {
        return this.selectDictLabel(this.orderStatusOptions, row.orderStatus);
      },
      /** 查询退款单列表 */
      getList() {
        this.loading = true;
        listRefund(this.queryParams).then(response => {
          this.refundList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 是否有效字典翻译
      isActiveFormat(row, column) {
        return this.selectDictLabel(this.isActiveOptions, row.isActive);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          isActive: undefined,
          lesseeId: undefined,
          userId: undefined,
          supplierId: undefined,
          orderId: undefined,
          orderSn: undefined,
          refundSn: undefined,
          refundStatus: "0",
          refundReason: undefined,
          remark: undefined,
          refundMoney: undefined,
          refundShipping: undefined,
          refundWay: undefined,
          supplierGoodsId: undefined,
          goodsName: undefined,
          goodsNumber: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length != 1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加退款单";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getRefund(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改退款单";
        });
      },
      /** 提交按钮 */
      submitForm: function() {
        const that = this;
        this.$refs["form"].validate(valid => {
          if (valid) {
            const moneyPaid = that.form.moneyPaid?Number(that.form.moneyPaid):0;
            const refundMoney = that.form.refundMoney?Number(that.form.refundMoney):0;
            if (refundMoney>moneyPaid) {
              that.msgError("【退款金额】不能大于【支付金额】")
              return
            }
            var params = {
              id: that.form.id,
              refundMoney: that.form.refundMoney
            };
            updateRefund(params).then(response => {
              if (response.code === 200) {
                that.msgSuccess("修改成功");
                that.open = false;
                that.getList();
              }
            });
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除退款单编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delRefund(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有退款单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportRefund(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
      },
      handleShowOrderList(row) {
        var that = this
        this.isShowOrderList = true
        getOrderInfo(row.orderId).then(response => {
          if (response.code === 200) {
            var list = []
            var obj = response.data
            if (obj.withdRawalId) {
              getWithdrawal(obj.withdRawalId).then(rs => {
                if (rs.code === 200) {
                  var withdRawalObj = rs.data
                  obj.withdState = withdRawalObj.withdState
                  list.push(obj)
                  that.orderList = list
                } else {
                  list.push(obj)
                  that.orderList = list
                }
              })
            } else {
              list.push(obj)
              that.orderList = list
            }
          }
        });
      },
      handleSetRemark() {
        let findObj = this.refundList.find(obj => {
          return obj.id == this.ids[0]
        })
        this.isShowRemarkInput = true
        this.remarkInputVal = findObj.kfRemark
      },
      saveApproval() {
        if (!this.approvalObject.approvalStatus) {
          this.msgError("请选择是否审批通过")
          return
        } else {
          var that = this;
          var params = {
            id: that.ids[0],
            approveUser: that.$store.state.user.name,
            approveUserName: that.$store.state.user.name,
            approveStatus: that.approvalObject.approvalStatus
          };
          toApprove(params).then(response => {
            that.showApproval = false
            that.approvalObject.approvalStatus = ''
            if (response.code === 200) {
              that.msgSuccess("操作成功");
              that.getList();
            } else {
              that.msgError(response.msg);
            }
          })
        }
      },
      closeApproval() {
        this.showApproval = false
        this.approvalObject.approvalStatus = ''
      },
      openApproval() {
        if (!this.ids || !this.ids.length) {
          this.msgError("请选择需审批数据")
          return
        }
        let findObj = this.refundList.find(obj => {
          return obj.id == this.ids[0]
        })
        if (findObj.approveStatus === 'APPROVING') {
          this.approvalObject.approvalStatus = findObj.approveStatus
          this.showApproval = true
        } else {
          this.msgError("当前退款单已审批过，不能再次审批")
        }
      },
      closeShowAmountInput() {
        this.isShowAmountInput = false
      },
      handleManualPayment() {
        if (!this.ids || !this.ids.length) {
          this.msgError("请选择需审批打款数据")
          return
        }
        let findObj = this.refundList.find(obj => {
          return obj.id == this.ids[0]
        })
        const that = this;
        if ((findObj.approveStatus === 'APPROVE_PASS') && (findObj.refundStatus === 'REFUNDING' || findObj.refundStatus === 'DISPOSING')) {
          that.refundRow = findObj;
          that.isShowAmountInput = true
        } else {
          this.msgError("当前退款单未满足退款条件")
        }
      },
      getCurrentTime() {
        //获取当前时间
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth() + 1;
        let dd = new Date().getDate();
        let hh = new Date().getHours();
        let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
        let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
        return (yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss)
      },
      systemRefundMoney() {
        const that = this;
        const moneyPaid = this.refundRow.moneyPaid?Number(this.refundRow.moneyPaid):0; // 支付金额
        const refundMoney = this.refundRow.refundMoney?Number(this.refundRow.refundMoney):0; // 退款金额
        if (refundMoney>moneyPaid) {
          that.msgError("【退款金额】不能大于【支付金额】")
          return
        }
        const params = {
          id: this.refundRow.id
        };
        systemRefund(params).then(response => {
          if (response.code === 200) {
            that.msgSuccess("打款成功");
            that.isShowAmountInput = false
            // this.amountInputVal = ""
            that.refundRow = {};
            that.getList();
          } else {
            that.msgError(response.msg)
          }
        });
      },
      handleEditData() {
        let params = {
          id: this.ids[0],
          kfRemark: this.remarkInputVal, //客服备注
          kfStatus: '1', // 客服是否处理 是否 0/1
          kfDate: this.getCurrentTime() // 客服处理时间：yyyy-MM-dd HH:mm:ss
        }
        updateRefund(params).then(response => {
          if (response.code === 200) {
            this.msgSuccess("修改成功");
            this.isShowRemarkInput = false
            this.remarkInputVal = ""
            this.getList();
          } else {
            this.msgError(response.msg)
          }
        });
      }
    }
  };
</script>
<style>
  .my-refund-row{
    width: 100%;
    font-size: 32rpx;
    margin-bottom: 15px;
  }
</style>
